#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;


z_Abs(x)
{
    if(x < 0)
        return 0 - x;
    
    return x;
}

z_GetCursorOrigin()
{
    eye = self getTagOrigin("tag_eye");
    curs = z_VectorScale(anglesToForward(self getPlayerAngles()), 1000000);
    return bulletTrace(eye, curs, 0, self)["position"];
}

z_GetCursorSurfaceType()
{
    eye = self getTagOrigin("tag_eye");
    curs = z_VectorScale(anglesToForward(self getPlayerAngles()), 1000000);
    return bulletTrace(eye, curs, 0, self)["surfacetype"];
}

z_VectorScale(vec, scale)
{
    return (vec[0] * scale, vec[1] * scale, vec[2] * scale);
}

z_WaittillGameCreated()
{
    while(!isDefined(level.zMain_GameCreated))
        wait(0.1);
}

z_Waittill13AnyReturn(s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12)
{
    if(s0 != "death" && s1 != "death" && s2 != "death" && s3 != "death" && s4 != "death" && s5 != "death"
    && s6 != "death" && s7 != "death" && s8 != "death" && s9 != "death" && s10 != "death" && s11 != "death" && s12 != "death")
        self endon("death");
    
    ent = spawnStruct();
    
    self thread waittill_string(s0, ent);
    self thread waittill_string(s1, ent);
    self thread waittill_string(s2, ent);
    self thread waittill_string(s3, ent);
    self thread waittill_string(s4, ent);
    self thread waittill_string(s5, ent);
    self thread waittill_string(s6, ent);
    self thread waittill_string(s7, ent);
    self thread waittill_string(s8, ent);
    self thread waittill_string(s9, ent);
    self thread waittill_string(s10, ent);
    self thread waittill_string(s11, ent);
    self thread waittill_string(s12, ent);
    
    ent waittill("returned", msg);
    ent notify("die");
    return msg;
}

z_WeaponModelManageTags(weapon, extratag0, extratag1, extratag2, extratag3, extratag4)
{
/*  WEAPON TAGS:
    
    "tag_silencer"
    "tag_red_dot"
    "tag_tavor_scope"
    "tag_thermal_scope"
    "tag_eotech"
    "tag_fn2000_scope"
    "tag_rail"
    "tag_rear_sight"
    "tag_iron_sight"
    "tag_sight_on"
    "tag_m203"
    "tag_gp25"
    "tag_shotgun"
    "tag_acog_2"
    "tag_sa80_scope"
    "tag_acog"
    "tag_steyr_scope"
    "tag_scope"
    "tag_m14ebr_scope"
    "tag_m82_scope"
    "tag_wa2000_scope"
    "tag_cheytac_scope"
    "tag_heartbeat"
    "tag_foregrip"
*/
    
    // получаем массив с лишними тегами
    hideTagList = getWeaponHideTags(weapon);
    
    if(!isDefined(hideTagList))
        return;
    
    // скрываем лишние теги
    for(i = 0; i < hideTagList.size; i++)
        self hidePart(hideTagList[i]);
    
    // добавляем дополнительные теги
    if(isDefined(extratag0))
        self showPart(extratag0);
    
    if(isDefined(extratag1))
        self showPart(extratag1);
    
    if(isDefined(extratag2))
        self showPart(extratag2);
    
    if(isDefined(extratag3))
        self showPart(extratag3);
    
    if(isDefined(extratag4))
        self showPart(extratag4);
}

